<?php

class App{
	
	private static $CSession;
	/**
	 * Specify where params array('namespace'=>null, 'controller'=>null....
	 * @var unknown
	 */
	private static $here = array();
	
	public static function init(){
		self::loadCore();
		self::$CSession = CSession::getInstance();
	}
	
	public static function CSession(){
		return self::$CSession;
	}
	
	public static function import($classpath){
	
		$p = str_replace(".", DS, $classpath);
		$p = ROOT.DS.$p.'.php';
	
		if(!file_exists($p)){
			throw new Exception('Class file not found on: '.$p);
		}
		else{
			require_once($p);
		}
	}
	public static function load($path, $class_name){
	
		$path = trim($path, '/');
		$classpath = ROOT.DS.APP_DIR.DS.$path.DS.$class_name.'.php';
	
		if(!file_exists($classpath)){
			throw new Exception('Class file not found on: '.$classpath);
		}
		else{
			require_once($classpath);
		}
	
	}
	
	public static function loadCore(){
		self::import('common.Core.App');
		self::import('common.Core.CRequest');
		self::import('common.Core.CResponse');
		self::import('common.Core.CDispatcher');
		self::import('common.Core.CSession');
		self::import('common.Core.CConfig');
		self::import('common.Controller.BaseController');
		self::import('common.Model.BaseModel');
		self::import('common.Log.CLog');
	}
	
	public static function here(){
		return self::$here;
	}
	
	public static function setHere($location){
		self::$here = $location;
	}
	
	
	
}


?>